package cn.sibu.disalllowtouchintercept;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.ImageView;

public class DragTouchActivity extends AppCompatActivity implements View.OnLongClickListener{


    private DropTargetView dropTargetView;
    private WebImageView webImageView;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        //为每个imageView关联长按监听器
        findViewById(R.id.image1).setOnLongClickListener(this);
        findViewById(R.id.image2).setOnLongClickListener(this);
        findViewById(R.id.image3).setOnLongClickListener(this);


        dropTargetView  = (DropTargetView) findViewById(R.id.drag_target1);
        webImageView = (WebImageView) findViewById(R.id.webimage);
        webImageView.setImageUrl("http://pics.sc.chinaz.com/files/pic/pic9/201512/apic16820.jpg");
    }

    @Override
    public boolean onLongClick(View v) {
        //View.DragShadowBuilder shadowBuilder = new View.DragShadowBuilder(v);
        DrawableDragShadowBuilder shadowBuilder = new DrawableDragShadowBuilder(v,((ImageView)v).getDrawable());
        //开始拖动,将view的图片作为本地状态传递出去
        v.startDrag(null, shadowBuilder, ((ImageView) v).getDrawable(), 0);

        return true;
    }


}
